<?php

/**
 * This is the model class for table "member".
 *
 * The followings are the available columns in table 'member':
 * @property integer $id_member
 * @property integer $id_groups
 * @property string $no_member
 * @property string $first_name
 * @property string $last_name
 * @property string $surname
 * @property string $alamat
 * @property string $email
 * @property string $award
 * @property string $birthday
 * @property integer $id_country
 * @property integer $id_kab
 * @property integer $jenkel
 * @property string $foto
 * @property string $created
 *
 * The followings are the available model relations:
 * @property Award[] $awards
 * @property Equipment[] $equipments
 * @property Country $idCountry
 * @property Groups $idGroups
 * @property Kabupaten $idKab
 * @property TeeTimeOnline[] $teeTimeOnlines
 */
class Member extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Member the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'member';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_groups, id_country, id_kab, jenkel', 'numerical', 'integerOnly'=>true),
			array('no_member, first_name, last_name, surname, email', 'length', 'max'=>45),
			array('alamat, award, birthday, foto, created', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_member, id_groups, no_member, first_name, last_name, surname, alamat, email, award, birthday, id_country, id_kab, jenkel, foto, created', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'awards' => array(self::HAS_MANY, 'Award', 'id_member'),
			'equipments' => array(self::HAS_MANY, 'Equipment', 'id_member'),
			'idCountry' => array(self::BELONGS_TO, 'Country', 'id_country'),
			'idGroups' => array(self::BELONGS_TO, 'Groups', 'id_groups'),
			'idKab' => array(self::BELONGS_TO, 'Kabupaten', 'id_kab'),
			'teeTimeOnlines' => array(self::HAS_MANY, 'TeeTimeOnline', 'id_member'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_member' => 'Id Member',
			'id_groups' => 'Id Groups',
			'no_member' => 'No Member',
			'first_name' => 'First Name',
			'last_name' => 'Last Name',
			'surname' => 'Surname',
			'alamat' => 'Alamat',
			'email' => 'Email',
			'award' => 'Award',
			'birthday' => 'Birthday',
			'id_country' => 'Id Country',
			'id_kab' => 'Id Kab',
			'jenkel' => 'Jenkel',
			'foto' => 'Foto',
			'created' => 'Created',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_member',$this->id_member);
		$criteria->compare('id_groups',$this->id_groups);
		$criteria->compare('no_member',$this->no_member,true);
		$criteria->compare('first_name',$this->first_name,true);
		$criteria->compare('last_name',$this->last_name,true);
		$criteria->compare('surname',$this->surname,true);
		$criteria->compare('alamat',$this->alamat,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('award',$this->award,true);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('id_country',$this->id_country);
		$criteria->compare('id_kab',$this->id_kab);
		$criteria->compare('jenkel',$this->jenkel);
		$criteria->compare('foto',$this->foto,true);
		$criteria->compare('created',$this->created,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}